package com.czx.task.dao;


import cn.hutool.core.bean.BeanUtil;
import com.alibaba.cloud.commons.lang.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.czx.task.domain.dto.TaskDTO;
import com.czx.task.domain.entity.Task;
import com.czx.task.domain.vo.TaskVO;
import com.czx.task.mapper.TaskMapper;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TaskDao extends ServiceImpl<TaskMapper, Task> {
    public List<TaskVO> getList(TaskDTO dto) {
        List<Task> tasks = baseMapper.selectList(new LambdaQueryWrapper<Task>()
                .like(StringUtils.isNotEmpty(dto.getTitle()),Task::getTitle, dto.getTitle())
                .like(StringUtils.isNotEmpty(dto.getDescription()),Task::getDescription, dto.getDescription()));
        return BeanUtil.copyToList(tasks, TaskVO.class);
    }
}
